Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

Controlling Digitization

This section describes the video digitizer component functions that allow applications to control video digitization. Video digitizer components allow applications to start and stop the digitizing process. Your application can request continuous digitization or single-frame digitization. When a digitizer component is operating continuously, it automatically places successive frames of digitized video into the specified destination. When a digitizer component works with a single frame at a time, the application and other software, such as an image compressor component, control the speed at which the digitized video is processed.

You can use the VDSetPlayThruOnOff function in your application to enable or disable digitization. When digitization is enabled, the video digitizer component places digitized video frame into the specified destination continuously. The application stops the digitizer by disabling digitization. This function can be used with both destination options.

Alternatively, your application can control digitization on a frame-by-frame basis. The VDGrabOneFrame and VDGrabOneFrameAsync functions digitize a single video frame; VDGrabOneFrame works synchronously, returning control to your application when it has obtained a complete frame, while VDGrabOneFrameAsync works asynchronously. The VDDone function helps you to determine when the VDGrabOneFrameAsync function is finished with a video frame. Your application can define the buffers for use with asynchronous digitization by calling the VDSetupBuffers function. Free the buffers by calling the VDReleaseAsyncBuffers function.

The VDSetFrameRate function allows applications to control the digitizer's frame rate. The VDGetDataRate function returns the digitizer's current data rate.

VDSetPlayThruOnOff

The VDSetPlayThruOnOff function allows applications to control continuous digitization.

pascal VideoDigitizerError VDSetPlayThruOnOff
                                          (VideoDigitizerComponent ci,
                                          short state);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.
state
A short integer that specifies whether to use continuous digitization. The following values are valid:
digitizerOff
Turns off continuous digitization
digitizerOn
Turns on continuous digitization
When an application stops continuous digitization, the video digitizer component must restore its alpha channel, blending mask, or key color settings to graphics mode.

DESCRIPTION

When opened, video digitizer components are always set to off, so that no digitization is taking place. Your application can use the VDSetPlayThruOnOff function to turn continuous digitization on and off.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

qtParamErr

-2202

Invalid parameter value

SEE ALSO

Applications can also use single-frame digitization by calling the VDGrabOneFrame or VDGrabOneFrameAsync function, described in the next section and on VDGrabOneFrameAsync , respectively.

VDGrabOneFrame

The VDGrabOneFrame function instructs the video digitizer component to digitize a single frame of source video.

All video digitizer components must support this function.

pascal VideoDigitizerError VDGrabOneFrame
                                         (VideoDigitizerComponent ci);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.

DESCRIPTION

The application specifies the destination for the digitized frame by calling either the VDSetPlayThruDestination function (described on VDSetPlayThruDestination ) or the VDSetPlayThruGlobalRect function (described on VDSetPlayThruGlobalRect ).

If the specified digitizer component is already digitizing continuously when the application calls VDGrabOneFrame , the digitizer component returns the next digitized frame and then stops. If the digitizer component is stopped, the component digitizes a single frame and then stops. To resume continuous digitization, applications should call the VDSetPlayThruOnOff function, which is described in the previous section.

The VDGrabOneFrame function supports synchronous single-frame video digitization--that is, the digitizer component does not return control to your application until it has successfully processed the next video frame. Some video digitizer components may also support asynchronous single-frame digitization. Applications can use asynchronous digitization by calling the VDGrabOneFrameAsync function, described on VDGrabOneFrameAsync .

RESULT CODE

noErr

0

No error

VDSetupBuffers

The VDSetupBuffers function allows applications to define output buffers for use with asynchronous grabs. Video digitizer components extract information about the spatial characteristics of the video destinations from these buffers.

pascal VideoDigitizerError VDSetupBuffers
                                         (VideoDigitizerComponent ci,
                                          VdigBufferRecListHandle bufferList);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.
bufferList
Contains a handle to a list of output buffers. This buffer list is contained in a buffer list structure. This structure is described in "The Buffer List Structure" . Note that the video digitizer component makes a copy of the buffer list--you may dispose of this handle when the function returns to your application.

If you are developing a video digitizer component, note that the matrix field in the buffer list structure contains a pointer to the matrix structure. It is your responsibility to copy that matrix structure.

SPECIAL CONSIDERATIONS

Applications must define the output buffers before starting an asynchronous grab.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

qtParamErr

-2202

Invalid parameter value

badDepth

-2207

Digitizer cannot accommodate specified depth

noDMA

-2208

Digitizer cannot use DMA to this destination

SEE ALSO

Applications instruct digitizer components to grab a single frame by calling the VDGrabOneFrameAsync function, which is described on VDGrabOneFrameAsync .

Applications free these buffers by calling the VDReleaseAsyncBuffers function, which is described next.

VDReleaseAsyncBuffers

The VDReleaseAsyncBuffers function allows an application to release the buffers that it allocates with the VDSetupBuffers function.

pascal VideoDigitizerError VDReleaseAsyncBuffers
                                         (VideoDigitizerComponent ci);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.

DESCRIPTION

Applications release the buffers used in an asynchronous grab by calling the VDReleaseAsyncBuffers function.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

SEE ALSO

Applications allocate buffers for asynchronous grabs by calling the VDSetupBuffers function, which is discussed in the previous section.

VDGrabOneFrameAsync

The VDGrabOneFrameAsync function instructs the video digitizer component to start to digitize asynchronously a single frame of source video. Because the component digitizes the video asynchronously, the application is free to do other things while the digitization is performed.

pascal VideoDigitizerError VDGrabOneFrameAsync
                                          (VideoDigitizerComponent ci,
                                         short buffer);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.
buffer
Identifies the next output buffer. The value of this parameter must correspond to a valid index into the list of buffers that you supply when your application calls the VDSetupBuffers function (which is described on VDSetupBuffers ). Note that this value is zero-based (that is, you must set this parameter to 0 to refer to the first buffer in the buffer list).
The video digitizer component uses this buffer for the next video frame (that is, the frame that will be digitized the next time the application calls the VDGrabOneFrameAsync function). In this manner, video digitizer components can quickly and efficiently prepare for the next video frame.
Some digitizer components may not allow your application to queue more than one asynchronous frame grab at a time. These components may not return control to your application until a previously requested grab has been completed.

DESCRIPTION

Applications determine when the digitizer component is finished with a frame by calling the VDDone function, which is described in the next section.

When calling the VDGrabOneFrameAsync function, the application specifies the next destination video buffer, allowing the digitizer component to quickly switch from the current buffer to the next buffer. In this manner, your application's ability to grab video at high frame rates is enhanced. See "Multiple Buffering" for a discussion of multiple-buffered video digitization.

Applications can determine whether a video digitizer component supports asynchronous frame grabbing by examining the output capability flags of the digitizer component. Specifically, if the digiOutDoesAsyncGrabs flag is set to 1, the digitizer component supports the VDGrabOneFrameAsync function and the VDDone function, which is described in the next section.

Applications can use the VDGetCurrentFlags function (described on VDGetCurrentFlags ) to retrieve the digitizer component's output capability flags. If a video digitizer component does not support asynchronous digitization, applications must use the VDGrabOneFrame function (described on VDGrabOneFrame ) to perform single-frame digitization.

If the specified digitizer component is already digitizing continuously when the application calls VDGrabOneFrameAsync , the digitizer component returns the next digitized frame and then stops. If the digitizer component is stopped, the component digitizes a single frame and then stops. To resume continuous digitization, applications should call the VDSetPlayThruOnOff function, which is described on VDSetPlayThruOnOff .

The VDGrabOneFrameAsync function also allows applications to use more than one destination buffer for the digitized video. The application defines these buffers by calling the VDSetupBuffers function (described on VDSetupBuffers ). The application specifies one of these destination buffers for the digitized frame when it calls the VDSetPlayThruDestination function (described on VDSetPlayThruDestination ) or the VDSetPlayThruGlobalRect function (described on VDSetPlayThruGlobalRect ).

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDDone

You can use the VDDone function in your application to determine if the VDGrabOneFrameAsync function is finished with a specific output buffer ( VDGrabOneFrameAsync is described in the previous section). Applications that use the VDGrabOneFrameAsync function to digitize video frames should call VDDone before working with a digitized image.

pascal VideoDigitizerError VDDone
                                         (VideoDigitizerComponent ci, short buffer);
ci
Specifies the video digitizer component for the request. Applications obtain this reference from the Component Manager's OpenComponent function.
buffer
Identifies the buffer for the operation. The value of this parameter must correspond to a valid index into the list of buffers you supply when your application calls the VDSetupBuffers function (which is described on VDSetupBuffers ). Note that this value is zero-based (that is, you must set this parameter to 0 to refer to the first buffer in the buffer list).

DESCRIPTION

If the VDDone function returns a 0 result, the video digitizer component has not finished the specified asynchronous frame grab. If the result is nonzero, the frame has been processed and the application can proceed to use the contents of the specified buffer.

Applications can determine whether a video digitizer component supports asynchronous frame grabbing by examining the output capability flags of the digitizer component. Specifically, if the digiOutDoesAsyncGrabs flag is set to 1, the digitizer component supports the VDGrabOneFrameAsync and VDDone functions. Applications can use the VDGetCurrentFlags function to retrieve the component's output capability flags. See VDGetCurrentFlags for a description of the VDGetCurrentFlags function.

The VDDone function returns a long integer indicating whether the specified asynchronous frame grab is complete. If the returned value is 0, the video digitizer component is still working on the frame. If the returned value is nonzero, the digitizer component is finished with the frame and the application can perform its processing.

VDSetFrameRate

The VDSetFrameRate function allows an application to indicate its desired frame rate to the video digitizer. Note that some digitizers may not be able to support high frame rates.

pascal VideoDigitizerError VDSetFrameRate
                                          (VideoDigitizerComponent ci,
                                          Fixed framesPerSecond);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
framesPerSecond
Specifies the application's desired frame rate. Applications may set this parameter to 0 to return the digitizer to its default frame rate (typically 29.97 frames per second).

DESCRIPTION

In some cases, the digitizer component may not be able to control its frame rate. These digitizers can run at only a single rate of speed. In this case, the digitizer returns a result code of digiUnimpErr .

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported

VDGetDataRate

The VDGetDataRate function allows an application to retrieve information that describes the performance capabilities of a video digitizer.

pascal VideoDigitizerError VDGetDataRate
                                         (VideoDigitizerComponent ci,
                                          long *milliSecPerFrame,
                                          Fixed *framesPerSecond,
                                          long *bytesPerSecond);
ci
Identifies the application's connection to the video digitizer component. An application obtains this value from the Component Manager's OpenComponent function.
milliSecPerFrame
Contains a pointer to a long integer. The video digitizer returns a value that indicates the number of milliseconds of synchronous overhead involved in digitizing a single frame. This value includes the average delay incurred between the time when the digitizer requests a frame from its associated device, and the time at which the device delivers the frame.
framesPerSecond
Contains a pointer to a fixed value. The video digitizer supplies the maximum rate at which it can capture video. Note that this value may differ from the rate that the application set with the VDSetFrameRate function, described in the previous section.
bytesPerSecond
Contains a pointer to a long integer. Video digitizers that can return compressed image data return a value that indicates the approximate number of bytes per second that the digitizer is generating compressed data, given the current compression settings and frame rate settings.

RESULT CODES

noErr

0

No error

digiUnimpErr

-2201

Function not supported


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next